<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Color Manila Run - Forgot Password</title>
<link rel="stylesheet" href="styles/layout.css" type="text/css" media="screen"/>
<script src="scripts/home.js"></script>
<script src="scripts/jquery-1.8.2.js"></script>
<script src="scripts/jquery.md5.js"></script>
<script src="scripts/jquery.sha1.js"></script>
<script src="scripts/textinputUtils.js"></script>
<script src="scripts/preloadercontrol.js"></script>

</head>
<body marginheight="0" marginwidth="0">
<div id="preloader"><div><img src="images/ajax-loader.gif" width="50" height="50"/></div></div>
<div id="regMainContainer" style="width:300px;">
	<div id="div-container">
		<div id="div-header">
			<div class="div-header-title">
				<div class="dh-title-left"></div>
				<div class="dh-title-center">Reset Password</div>
				<div class="dh-title-right"></div>
			</div>
		</div>
		<div id="div-content">
			<div class="formItem">
				<div class="formLabelRight" style="width:150px;"><font color="#ff0000">*</font>Email address</div>
				<div>
				<input type="text" name="emailAdd" class="formInputEmail" maxlength="50" value=""/>
				</div>
			</div>
			<div id="emailErrorMsg" class="formErrorMsg"></div>
			<div class="divSpacer"></div>
			<div id="resetResult">&nbsp;</div>
			<div class="divSpacer"></div>
			<div id="registerButtonMenu">
				<div id="registerButton">
					<div class="blue-buttonBL"></div>
					<div id="btnContinue" class="blue-buttonM">
					<a href="javascript:forgotPasswordSubmit()">Submit</a>
					</div>
					<div class="blue-buttonBR"></div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>

$("#preloader").css({ opacity: 0.5 });
showPreloader(false);
$("#regMainContainer").click(function()
{
	$(".formInputEmail").blur(function(e){
		validateEmailAddress(e, $("#emailErrorMsg"));
	}); 
});

var toHomeBtn = "<a href=\"main.php\">Back</a>";

function forgotPasswordSubmit()
{
	var resetObj = {};
	resetObj.username = $("#regMainContainer").find( 'input[name="emailAdd"]' ).val();
	if(resetObj.username == "")
	{
		$("#emailErrorMsg").empty().append("Email cannot be empty.");
		return;
	}
	
	showPreloader(true);
	$.post("resetpassword.php", resetObj, function(data) {
		if(data == 0)
		{
			//window.location = "main.php";
			$("#resetResult").empty().append( "<b>An email has been sent for your new temporary password.</b>" );
			$("#btnContinue").empty().append(toHomeBtn);
		}
		else
			$("#emailErrorMsg").empty().append(data);
		
    	showPreloader(false);
    });
}
</script>
</html>